
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>

namespace ABV_UNICODE_NNTS_MAP {

	namespace bad {
		int main()
		{
			wchar_t wstrTestNNTS[] = L"0123456789ABCDEF";
			char strTestNNTS[16];
			int res = WideCharToMultiByte(CP_UTF8, 0, wstrTestNNTS, -1, strTestNNTS, 16, NULL, NULL);
			printf("res = %d\n", res);
			printf("strTestNNTS = %s\n", strTestNNTS);
			return 0;
		}
	}


	namespace good {
		int main()
		{
			wchar_t wstrTestNNTS[] = L"0123456789ABCDEF";
			char strTestNNTS[16];
			int res = WideCharToMultiByte(CP_UTF8, 0, wstrTestNNTS, -1, strTestNNTS, 16, NULL, NULL);
			if (res == sizeof(strTestNNTS)) {
				strTestNNTS[res - 1] = NULL;
			}
			else {
				strTestNNTS[res] = NULL;
			}
			printf("res = %d\n", res);
			printf("strTestNNTS = %s\n", strTestNNTS);
			return 0;
		}
	}
}